package com.hm.pan.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hm.pan.annotation.CheckLogin;
import com.hm.pan.model.OfflineHistory;
import com.hm.pan.model.ResultObj;
import com.hm.pan.model.User;
import com.hm.pan.service.OfflineHistoryService;

@RestController
@RequestMapping("offline")
@CheckLogin
public class OfflineHistoryController {

	@Resource
	private OfflineHistoryService offlineHistoryService;

	@GetMapping("getAllOfflineTask")
	public Object getAllOfflineTask(HttpSession session) {
		ResultObj resultObj = new ResultObj();
		User user = (User) session.getAttribute("user");

		try {
			OfflineHistory offlineHistory = new OfflineHistory();
			offlineHistory.setUserId(user.getUserId());
			resultObj.setStatusCode(200);
			resultObj.setMessage("获取成功");
			resultObj.setData(offlineHistoryService.findAllOfflineHistory(offlineHistory));
		} catch (Exception e) {
			e.printStackTrace();
		}

		resultObj.setStatusCode(500);
		resultObj.setMessage("获取失败");
		return resultObj;
	}

}
